; (function () {
    axios.defaults.baseURL = 'http://127.0.0.1:3000';
    axios.defaults.timeout = 3000;

    class NJHttp {
        static get(url = "", data = "") {
            return new Promise(function (resolve, reject) {
                axios.get(url, {
                    params: data
                })
                    .then(function (response) {
                        resolve(response.data)
                    })
                    .catch(function (error) {
                        reject(error)
                    });
            })
        }
        static post(url = "", data = "") {
            return new Promise(function (resolve, reject) {
                axios.post(url, {
                    params: data
                })
                    .then(function (response) {
                        resolve(response.data)
                    })
                    .catch(function (error) {
                        reject(error)
                    });
            })
        }
    }
    class HomeApis {
        static getHomeBanner() {
            return NJHttp.get("/banner", {type: 2});
        }
        static getHomeRecommend() {
            return NJHttp.get("/personalized");
        }
        static getHomeExclusive() {
            return NJHttp.get("/personalized/privatecontent");
        }
        static getHomeAlbum() {
            return NJHttp.get("/top/album?offset=0&limit=30&year=2019&month=6");
        }
        static getHomeMv() {
            return NJHttp.get("/personalized/mv");
        }
        static getHomeDj() {
            return NJHttp.get("/personalized/djprogram");
        }

        static getHomeHotDetail() {
            return NJHttp.get("/search/hot/detail");
        }
        static getHomeSearchSuggest(keywords) {
            return NJHttp.get("/search/suggest?keywords="+ keywords +"&type=mobile");
        }
    }

    class SearchApis {
        static getSearch(keywords="", offset=0, limit=30, type=1) {
            return NJHttp.get("/search", {
                keywords:keywords,
                offset:offset,
                limit:limit,
                type:type
            })
        }
    }
    class MusicApis {
        static getSongDetail(ids){
            return NJHttp.get("song/detail", {
                ids: ids
            })
        }
        static getSongURL(id) {
            return NJHttp.get("song/url", {
                id: id
            })
        }
        static getSongLyric(id){
            return NJHttp.get("/lyric",{
                id:id
            })
        }
    }
    window.NJHttp = NJHttp;
    window.HomeApis = HomeApis;
    window.SearchApis = SearchApis;
    window.MusicApis = MusicApis;
})()
